package com.example.demo.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.example.demo.mapper.UserMapper;
import com.example.demo.pojo.User;
import com.example.demo.service.UserService;

@Service
@Transactional
public class UserServiceImpl implements UserService {
	@Autowired
	private UserMapper userMapper;

	@Override
	public void addUser(User user) {
		userMapper.insertUser(user);
	}

	@Override
	public List<User> findAllUser() {
		List<User> users = userMapper.selectAllUser();
		return users;
	}

	@Override
	public User findUserById(Integer id) {
		User user = userMapper.selectUserById(id);
		return user;
	}

	@Override
	public void changeUser(User user) {
		userMapper.updateUser(user);
	}

	@Override
	public void deleteUserById(Integer id) {
		userMapper.deleteUserById(id);
	}
}
